#ifndef _YL_GROUP_TREE_VIEW_
#define _YL_GROUP_TREE_VIEW_

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace yoctolog_viewer {

	/// <summary>
	/// Summary for GroupTreeView
	/// </summary>
	public ref class GroupTreeView : public System::Windows::Forms::TreeView
	{
	private: System::Void OnAfterSelect(System::Object^  sender, System::Windows::Forms::TreeViewEventArgs^  e);
			 ref class SessionData ^		m_pSessionData;
			 
	public:
		GroupTreeView()
		{
			InitializeComponent();

			this->AfterSelect += gcnew System::Windows::Forms::TreeViewEventHandler(this, &GroupTreeView::OnAfterSelect);
			
			this->DrawMode = TreeViewDrawMode::OwnerDrawText;
			this->DrawNode += gcnew DrawTreeNodeEventHandler( this, &GroupTreeView::OnDrawNode );

			this->MouseDown += gcnew MouseEventHandler( this, &GroupTreeView::OnMouseDown );
		}

		void SetSessionData(ref class SessionData ^pSessionData)
		{
			m_pSessionData = pSessionData;
		}

		void UpdateGroups();
		TreeNode ^CreateOrGetNode(String ^strNode);
		void OnDrawNode( Object^ sender, DrawTreeNodeEventArgs^ e );

		delegate void GroupSelectedDelegate(ref class LogMessageGroup ^pGroup);
		GroupSelectedDelegate ^GroupSelected;

		Rectangle NodeBounds( TreeNode^ node );
		void OnMouseDown( Object^ /*sender*/, MouseEventArgs^ e );

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~GroupTreeView()
		{
			if (components)
			{
				delete components;
			}
		}

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
		}
#pragma endregion
	};
}


#endif